import { useRoute, useRouter } from 'vue-router'
import { ArticeApi } from '../article-manage/article-list/api'
import { ref } from 'vue'

export class ArticleClass {
	route = useRoute()
	router = useRouter()
	articleInfo = ref()
	constructor() {
		this.getDetails()
	}

	/**
	 * 获取文章详情
	 */
	public getDetails() {
		const params = {
			id: this.route.query.id
		}
		ArticeApi.queryArticleDetails(params).subscribe((res: any) => {
			this.articleInfo.value = res
		})
	}

	/**
	 * 跳转后台
	 */
	public toWeb() {
		this.router.push({ name: 'ArticleList' })
	}

	public logout() {
		localStorage.removeItem('token')
		this.router.replace('/login')
	}
}
